<?php
$this->set('title_for_layout','Miasta GDG');
?><h1>GDG w Polsce</h1>
<ul class="chapter-list">
    <?php foreach($chapters as $chapter): ?>
    <li><?php 
    $chapterImage = null;
    if(!empty($chapter['Chapter']['image'])){
        $chapterImage = $chapter['Chapter']['image'];
    } 
    $chapterUrl = "/";
    if(empty($chapter['Chapter']['url'])){
        $chapterUrl = $this->Html->url(array('controller'=>'chapters','action'=>'view','slug'=>$chapter['Chapter']['slug']));
    } else {
        $chapterUrl = $chapter['Chapter']['url'];
    }
    ?><a href="<?= $chapterUrl ?>" title="Idź do strony<?=$chapter['Chapter']['name']?>" rel="chapter">
        <?php if($chapterImage){ echo $this->Html->image('/static/gdglogo/'.$chapterImage,array('class'=>'chapter', 'alt'=> ' Logo ' . $chapter['Chapter']['name'])); } else { echo $chapter['Chapter']['name']; } ?>
    </a>
    </li>
    <?php endforeach; ?>
</ul>